package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.common.util.DateUtils;
import com.softer.wxzj.entity.AccKeepAccount;
import com.softer.wxzj.entity.SettleAccounts;
import com.softer.wxzj.service.AccKeepAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * RefPayInfoController class
 *
 * @author wxr
 * @date 2019/7/1
 */
@RestController
@RequestMapping("/accKeepAccount")
@Slf4j
public class AccKeepAccountController {

    @Autowired
    AccKeepAccountService accKeepAccountService;

    /**
     * 交易信息查询列表
     *
     * @param page
     * @param accKeepAccount
     * @return
     */
    @RequestMapping("/getTransInfoList")
    @LogRecord(description = "交易信息查询列表", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public PageInfo<AccKeepAccount> getTransInfoList(Page page, AccKeepAccount accKeepAccount) {
        return accKeepAccountService.getTransInfoList(page, accKeepAccount);
    }

    /**
     * 查询业务编号
     *
     * @return
     */
    @RequestMapping("/getPayNo")
    @LogRecord(description = "查询业务编号", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public List<AccKeepAccount> getPayNo() {
        return accKeepAccountService.getPayNo();
    }

    /**
     * 查询单个数据
     *
     * @param id
     * @return
     */
    public AccKeepAccount getInfo(String id) {
        return accKeepAccountService.getInfo(id);
    }

    /**
     * 点击查看验证
     */
    @RequestMapping("/getInfoById")
    @LogRecord(description = "点击查看验证", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public AccKeepAccount getInfoById(String id, String verificationTime) {
        return accKeepAccountService.getInfoById(id, verificationTime);
    }

    /**
     * 查询列表
     *
     * @param page
     * @param accKeepAccount
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "查询列表", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public PageInfo<AccKeepAccount> getList(Page page, AccKeepAccount accKeepAccount) {
        return accKeepAccountService.getList(page, accKeepAccount);
    }

    /**
     * 记账
     *
     * @param accKeepAccount
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "记账", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.UPDATE)
    public CommonResult update(AccKeepAccount accKeepAccount) {
        return accKeepAccountService.update(accKeepAccount);
    }

    /**
     * 记账
     *
     * @param id
     * @return
     */
    @RequestMapping("/getListInfo")
    @LogRecord(description = "记账", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public AccKeepAccount getListInfo(String id) {
        return accKeepAccountService.getListInfo(id);
    }

    /**
     * 冲正
     *
     * @param id
     * @return
     */
    @RequestMapping("/reverse")
    @LogRecord(description = "冲正", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.UPDATE)
    public CommonResult reverse(String id) {
        return accKeepAccountService.reverse(id);
    }

    /**
     * 获取当前日期
     *
     * @return
     */
    @RequestMapping("/time")
    @LogRecord(description = "获取当前日期", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public String time() {
        return DateUtils.getDateNow();
    }


    /**
     * 获取当前日期
     *
     * @return
     */
    @RequestMapping("/tallyTime")
    @LogRecord(description = "获取记账日期", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public String tallyTime(String bankCode) {
        return accKeepAccountService.tallyTime(bankCode);
    }

    /**
     * 日终核对第一个列表
     *
     * @return
     */
    @RequestMapping("/getCountList")
    @LogRecord(description = "日终核对第一个列表", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public PageInfo<SettleAccounts> getCountList(Page page, SettleAccounts settleAccounts) {
        return accKeepAccountService.getCountList(page, settleAccounts);

    }

    /**
     * 日终核对-核对-列表
     * CDG 2019-07-31
     */
    @RequestMapping("/getListByBankCodeAndTallyTime")
    @LogRecord(description = "日终核对-核对-列表", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public PageInfo<AccKeepAccount> getListByBankCodeAndTallyTime(Page page, AccKeepAccount accKeepAccount, String fuzzy) {
        return accKeepAccountService.getListByBankCodeAndTallyTime(page, accKeepAccount, fuzzy);
    }

    /**
     * 日终核对-核对-列表-核对,初始核对
     * CDG 2019-07-31
     */
    @RequestMapping("/check")
    @LogRecord(description = "日终核对-核对-列表-核对", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.UPDATE)
    public CommonResult check(String ids, String state, String arcType) {
        return accKeepAccountService.check(ids, state, arcType);
    }

    /**
     * 查询该天有没有未核对的数据
     */
    @RequestMapping("/selectState")
    @LogRecord(description = "查询该天有没有未核对的数据", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public CommonResult selectState(String bankCode, String tallyTime) {
        return accKeepAccountService.selectState(bankCode, tallyTime);
    }

    /**
     * 日终核对---批量结算查询收入支付
     *
     * @param bankCode       银行idgetList
     * @param tallyTimeStart 开始时间（结算时间）
     * @param tallyTimeEnd   结算时间（最大当天时间）
     * @return 返回  SettleAccounts 实体
     */
    @RequestMapping("/batchSettlementInquiry")
    @LogRecord(description = "批量结算弹框加载数据", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public SettleAccounts batchSettlementInquiry(String bankCode, String tallyTimeStart, String tallyTimeEnd) {
        return accKeepAccountService.batchSettlementInquiry(bankCode, tallyTimeStart, tallyTimeEnd);
    }

    /**
     * 日终核对---批量结算--确定结算
     *
     * @param bankCode       银行id
     * @param tallyTimeStart 开始时间（结算时间）
     * @param tallyTimeEnd   结算时间（最大当天时间）
     * @return 返回  CommonResult
     */
    @RequestMapping("/Settlement")
    @LogRecord(description = "批量结算——确定结算", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.UPDATE)
    public CommonResult settlement(String bankCode, String tallyTimeStart, String tallyTimeEnd) {
        return accKeepAccountService.settlement(bankCode, tallyTimeStart, tallyTimeEnd);
    }

}
